package timer

import (
  "livefind/config"
  "livefind/global"
  "livefind/utils"
  "livefind/utils/logger"
)

func init()  {
  if global.GVA_CONFIG.Timer.Start {
    for _, detail := range global.GVA_CONFIG.Timer.Detail {
      go func(detail config.Detail) {
        global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() {
          err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval)
          if err != nil {
            logger.Error(err.Error(),err)
          }
        })
      }(detail)
    }
  }
}
